
import { EXTENSION_PATH, exeCommand, AssetDB, findFile, FindFileType, copyDirectory, getGamePacks, getExtensionConfig } from './utils';

const OS = require('os');
const FS = require('fs');
const Path = require('path');

const econfig = getExtensionConfig();

/**
 * 导入框架
 */
function importFramework() {
	let sources = Path.join(EXTENSION_PATH, 'assets');
    let target = `db://assets/${econfig.name}/`;
    
	// 如果已经导入寻找目标目录
	let path = findFile(Path.join(Editor.Project.path, 'assets'), econfig.name, FindFileType.DIRECTORY);
	if(path){
		target = "db://" + path.substring(path.indexOf("assets")).replace("\\","/");
	}
    AssetDB.importAsset(sources, target, { overwrite : true });
}

/**
 * 插件加载回调
 */
export function load(){
	// 当 package 被正确加载的时候执行
	
}

/**
 * 插件卸载回调
 */
export function unload(){
	// 当 package 被正确卸载的时候执行
	
}

/**
 * 插件函数集合
 */
export namespace methods {
	/**
	 * 导入或更新框架
	 */
	export function import_framework(){
		importFramework();
	}

    /**
     * 打开设置界面
     */
    export function function_panel(){
        Editor.Panel.open(`${econfig.name}.settings`);
    }
};
